package de.tabuma.pm.externalcontent.logik;

import de.tabuma.pm.externalcontent.entity.ExternalContent;
import de.tabuma.pm.logik.*;
import de.tabuma.pm.externalproject.entity.*;

import java.util.*;

/**
  * @author $Author: $
  * @version $Revision: $
  * @since $Date: $
 */
public class ExternalContentFacade {

    public static int create(ExternalContent en, String user) {
        return (int) PMF.doCreate(en, user);
    }

    public static ExternalContent get(int ID) {
        return PMF.get(ID, new ExternalContent());
    }

    public static void update (ExternalContent en, String user) {
        PMF.doUpdate(en, user);
    }

    public static void remove(int ID, String user) {
        ExternalContent ec = get(ID);
        PMF.doRemove(ec, user);
    }

    public static ExternalContent getWithNavigationId(int navigationId) {
        String keys[] = new String[1];
        keys[0] = "navigationId";
        String values[] = new String[1];
        values[0] = ""+navigationId;
        List<ExternalContent> exList = PMF.get(keys, values, new ExternalContent());
        if(exList.size()>0) {
            return exList.get(0);
        }
        return null;
    }
}
